import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Layout from '@/layout'

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/home/index'),
        name: 'index',
        meta: { title: '数据统计', icon: 'el-icon-coin', affix: true }
      }
    ]
  },
  {
    path: '/good',
    name: 'good',
    redirect: 'good_index',
    component: Layout,
    meta: { title: '商品管理', icon: 'el-icon-s-help' },
    children:[
      {
        path:'good_index',
        name:'good_index',
        meta: { title: '商品列表', icon: '' },
        component: () => import('@/views/good')
      },
      {
        path:'good_add',
        name:'good_add',
        meta: { title: '商品编辑', icon: '' },
        component: () => import('@/views/good/add')
      },
      {
        path:'good_classify',
        name:'good_classify',
        meta: { title: '商品分类', icon: '' },
        component: () => import('@/views/good/classify')
      }
    ]
  },
  {
    path: '/order',
    name: 'order',
    redirect: 'order_index',
    component: Layout,
    meta: { title: '订单管理', icon: 'el-icon-s-order' },
    children:[
      {
        path:'order_index',
        name:'order_index',
        meta: { title: '拼团订单', icon: '' },
        component: () => import('@/views/order')
      },
      {
        path:'order_personal',
        name:'order_personal',
        meta: { title: '单购订单', icon: '' },
        component: () => import('@/views/order/personal')
      },
      {
        path:'/order_detail',
        name:'order_detail',
        hidden: true,
        meta: { title: '订单详情', icon: '', noKeepAlive: true, },
        component: () => import('@/views/order/detail')
      }
    ]
  },
  {
    path: '/user',
    name: 'user',
    redirect: 'user_index',
    component: Layout,
    meta: { title: '用户管理', icon: 'el-icon-user-solid' },
    children:[
      {
        path:'user_index',
        name:'user_index',
        meta: { title: '用户列表', icon: '' },
        component: () => import('@/views/user')
      }
    ]
  },
  {
    path: '/withdraw',
    name: 'withdraw',
    redirect: 'withdraw_index',
    component: Layout,
    meta: { title: '提现管理', icon: 'el-icon-s-finance' },
    children:[
      {
        path:'withdraw_index',
        name:'withdraw_index',
        meta: { title: '提现列表', icon: '' },
        component: () => import('@/views/withdraw')
      }
    ]
  },
  {
    path: '/service',
    name: 'service',
    redirect: 'service_index',
    component: Layout,
    meta: { title: '售后管理', icon: 'el-icon-s-flag' },
    children:[
      {
        path:'service_index',
        name:'service_index',
        meta: { title: '退货列表', icon: '' },
        component: () => import('@/views/service')
      },
      {
        path:'service_exchange',
        name:'service_exchange',
        meta: { title: '换货列表', icon: '' },
        component: () => import('@/views/service/exchange')
      }
    ]
  },
  {
    path: '/express',
    name: 'express',
    redirect: 'express_index',
    component: Layout,
    meta: { title: '配送设置', icon: 'el-icon-s-promotion' },
    children:[
      {
        path:'express_index',
        name:'express_index',
        meta: { title: '运费模板', icon: '' },
        component: () => import('@/views/express')
      }
    ]
  },
  {
    path: '/setting',
    name: 'setting',
    redirect: 'setting_index',
    component: Layout,
    meta: { title: '系统设置', icon: 'el-icon-s-tools' },
    children:[
      {
        path:'setting_index',
        name:'setting_index',
        meta: { title: '账号管理', icon: '' },
        component: () => import('@/views/setting')
      },
      {
        path:'setting_role',
        name:'setting_role',
        meta: { title: '角色管理', icon: '' },
        component: () => import('@/views/setting/role')
      },
      {
        path:'setting_power',
        name:'setting_power',
        meta: { title: '权限管理', icon: '' },
        component: () => import('@/views/setting/power')
      }
    ]
  },
  {
    path: '/login',
    name:"login",
    component: () => import('@/views/login/index'),
    hidden: true
  }
]

const router = new VueRouter({
  routes
})

export default router
